﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace _0712502_0712504_DesignPatternGame
{
    // Bullet Manager
    public class BulletManager
    {
        public List<Bullet> _listBullets;
        public BulletManager()
        {
            _listBullets = new List<Bullet>();
        }

        public void DrawToScreen(GameTime gameTime, SpriteBatch spriteBatch)
        {
            foreach (Bullet iBullet in _listBullets)
            {
                iBullet.DrawToScreen(gameTime, spriteBatch);
            }
        }

        public void AddNewBulletToList(Bullet bullet)
        {
            _listBullets.Add(bullet);
        }
       
        public void Update(GameTime gameTime)
        {
            for (int i = 0; i < _listBullets.Count(); i++)
            {
                _listBullets.ElementAt(i).Update(gameTime);
                if (_listBullets.ElementAt(i).StateUsed == StateInUse.NotUsed)
                {
                    _listBullets.RemoveAt(i);
                }
            }
        }
    }
}
